<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type="checkbox" name="language" value="cpp">cpp
    <input type="checkbox" name="language" value="java">java
    <input type="checkbox" name="language" value="javascript">javascript
    <input type="checkbox" name="language" value="python">python <br/>
    <button id="selectAll">全选</button>
    <button id="selectAllback">全不选</button>
    <button id="backSelect">反选</button>
</body>
<script>
    //实现按钮的反选、全选、全不选
    var selectAll=document.getElementById("selectAll");
    var checkbox=document.getElementsByName("language");
    selectAll.onclick=function(){
        for(var i=0;i<checkbox.length;i++)
        {
            checkbox[i].checked=true;
        }
    }
    var selectAllback=document.getElementById("selectAllback");
    selectAllback.onclick=function(){
        for(var i=0;i<checkbox.length;i++)
        {
            checkbox[i].checked=false;
        }
    }
    var backSelect=document.getElementById("backSelect");
    backSelect.onclick=function(){
        for(var i=0;i<checkbox.length;i++)
        {
            checkbox[i].checked=!checkbox[i].checked;
        }
    }
</script>
</html>